// Decompiled by GOOSIN CO,LTD Copyright 2010 Pavel Kouznetsov.
// home page: http://www.Goosin.net
// Decompiler options: packimports(3) fieldsfirst ansi space 
// Source File Name:   getStaticReport_ok.java

package stock.analyse;

import include.get_sql.getInsertSql;
import include.nseer_cookie.NseerId;
import include.nseer_cookie.counter;
import include.nseer_db.nseer_db_backup1;
import java.io.IOException;
import java.net.URL;
import java.sql.ResultSet;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.servlet.ServletException;
import javax.servlet.http.*;
import javax.servlet.jsp.JspFactory;

public class getStaticReport_ok extends HttpServlet
{

	public getStaticReport_ok()
	{
	}

	public synchronized void service(HttpServletRequest request, HttpServletResponse response)
		throws IOException, ServletException
	{
		HttpSession dbSession = request.getSession();
		JspFactory _jspxFactory = JspFactory.getDefaultFactory();
		javax.servlet.jsp.PageContext pageContext = _jspxFactory.getPageContext(this, request, response, "", true, 8192, true);
		javax.servlet.ServletContext dbApplication = dbSession.getServletContext();
		HttpSession session = request.getSession();
		nseer_db_backup1 stock_db = new nseer_db_backup1(dbApplication);
		nseer_db_backup1 stock_db1 = new nseer_db_backup1(dbApplication);
		getInsertSql getInsertSql = new getInsertSql();
		counter count = new counter(dbApplication);
		try
		{
			if (stock_db.conn((String)dbSession.getAttribute("unit_db_name")) && stock_db1.conn((String)dbSession.getAttribute("unit_db_name")))
			{
				String time = "";
				Date now = new Date();
				SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
				time = formatter.format(now);
				String time1 = (new StringBuilder(String.valueOf(time))).append(" 00:00:00").toString();
				String time2 = (new StringBuilder(String.valueOf(time))).append(" 23:59:59").toString();
				String register_ID = (String)session.getAttribute("human_IDD");
				String register = (String)session.getAttribute("realeditorc");
				Date now1 = new Date();
				SimpleDateFormat formatter1 = new SimpleDateFormat("yyyyMMdd");
				String timea = formatter1.format(now1);
				String static_report_ID = NseerId.getId(getClass().getResource("").toString(), (String)dbSession.getAttribute("unit_db_name"));
				String sql1 = "select * from stock_balance_details_details";
				String sql2;
				for (ResultSet rs1 = stock_db.executeQuery(sql1); rs1.next(); stock_db1.executeUpdate(sql2))
					sql2 = (new StringBuilder("insert into stock_balance_static_report_details_details(STATIC_REPORT_ID,STATIC_REPORT_TIME,REGISTER_ID,REGISTER,CHAIN_ID,CHAIN_NAME,PRODUCT_ID,PRODUCT_NAME,PRODUCT_DESCRIBE,AMOUNT_UNIT,AMOUNT,MAX_CAPACITY_AMOUNT,MAX_AMOUNT,MIN_AMOUNT,COST_PRICE,SUBTOTAL,STOCK_ID,STOCK_NAME,NICK_NAME,CHECK_TAG,UNIQUE_TAG,REGISTER_TIME,STOCK_GATHER_GROUP_ID,SERIAL_NUMBER,TYPE,BALANCE_TYPE ) values('")).append(static_report_ID).append("','").append(time).append("','").append(register_ID).append("','").append(register).append("','").append(rs1.getString("CHAIN_ID")).append("','").append(rs1.getString("CHAIN_NAME")).append("','").append(rs1.getString("PRODUCT_ID")).append("','").append(rs1.getString("PRODUCT_NAME")).append("','").append(rs1.getString("PRODUCT_DESCRIBE")).append("','").append(rs1.getString("AMOUNT_UNIT")).append("','").append(rs1.getString("AMOUNT")).append("','").append(rs1.getString("MAX_CAPACITY_AMOUNT")).append("','").append(rs1.getString("MAX_AMOUNT")).append("','").append(rs1.getString("MIN_AMOUNT")).append("','").append(rs1.getString("COST_PRICE")).append("','").append(rs1.getString("SUBTOTAL")).append("','").append(rs1.getString("STOCK_ID")).append("','").append(rs1.getString("STOCK_NAME")).append("','").append(rs1.getString("NICK_NAME")).append("','").append(rs1.getString("CHECK_TAG")).append("','").append(rs1.getString("UNIQUE_TAG")).append("','").append(rs1.getString("REGISTER_TIME")).append("','").append(rs1.getString("STOCK_GATHER_GROUP_ID")).append("','").append(rs1.getString("SERIAL_NUMBER")).append("','").append(rs1.getString("TYPE")).append("','").append(rs1.getString("BALANCE_TYPE")).append("')").toString();

				String sql3 = "select * from stock_balance_details";
				String sql4;
				for (ResultSet rs3 = stock_db.executeQuery(sql3); rs3.next(); stock_db1.executeUpdate(sql4))
					sql4 = (new StringBuilder("insert into stock_balance_static_report_details(STATIC_REPORT_ID,STATIC_REPORT_TIME,REGISTER_ID,REGISTER,CHAIN_ID,CHAIN_NAME,PRODUCT_ID,PRODUCT_NAME,PRODUCT_DESCRIBE,AMOUNT_UNIT,AMOUNT,MAX_CAPACITY_AMOUNT,MAX_AMOUNT,MIN_AMOUNT,COST_PRICE,SUBTOTAL,STOCK_ID,STOCK_NAME,NICK_NAME,CHECK_TAG,UNIQUE_TAG,REGISTER_TIME,TYPE,BALANCE_TYPE ) values('")).append(static_report_ID).append("','").append(time).append("','").append(register_ID).append("','").append(register).append("','").append(rs3.getString("CHAIN_ID")).append("','").append(rs3.getString("CHAIN_NAME")).append("','").append(rs3.getString("PRODUCT_ID")).append("','").append(rs3.getString("PRODUCT_NAME")).append("','").append(rs3.getString("PRODUCT_DESCRIBE")).append("','").append(rs3.getString("AMOUNT_UNIT")).append("','").append(rs3.getString("AMOUNT")).append("','").append(rs3.getString("MAX_CAPACITY_AMOUNT")).append("','").append(rs3.getString("MAX_AMOUNT")).append("','").append(rs3.getString("MIN_AMOUNT")).append("','").append(rs3.getString("COST_PRICE")).append("','").append(rs3.getString("SUBTOTAL")).append("','").append(rs3.getString("STOCK_ID")).append("','").append(rs3.getString("STOCK_NAME")).append("','").append(rs3.getString("NICK_NAME")).append("','").append(rs3.getString("CHECK_TAG")).append("','").append(rs3.getString("UNIQUE_TAG")).append("','").append(rs3.getString("REGISTER_TIME")).append("','").append(rs3.getString("TYPE")).append("','").append(rs3.getString("BALANCE_TYPE")).append("')").toString();

				String sql5 = "select * from stock_balance";
				String sql6;
				for (ResultSet rs5 = stock_db.executeQuery(sql5); rs5.next(); stock_db1.executeUpdate(sql6))
					sql6 = (new StringBuilder("insert into stock_balance_static_report(STATIC_REPORT_ID,STATIC_REPORT_TIME,REGISTER_ID,REGISTER,CHAIN_ID,CHAIN_NAME,PRODUCT_ID,PRODUCT_NAME,PRODUCT_DESCRIBE,AMOUNT_UNIT,COST_PRICE_SUM,AMOUNT,COST_PRICE,ADDRESS_GROUP,REGISTER_TIME,TYPE,BALANCE_TYPE) values('")).append(static_report_ID).append("','").append(time).append("','").append(register_ID).append("','").append(register).append("','").append(rs5.getString("CHAIN_ID")).append("','").append(rs5.getString("CHAIN_NAME")).append("','").append(rs5.getString("PRODUCT_ID")).append("','").append(rs5.getString("PRODUCT_NAME")).append("','").append(rs5.getString("PRODUCT_DESCRIBE")).append("','").append(rs5.getString("AMOUNT_UNIT")).append("','").append(rs5.getString("COST_PRICE_SUM")).append("','").append(rs5.getString("AMOUNT")).append("','").append(rs5.getString("COST_PRICE")).append("','").append(rs5.getString("ADDRESS_GROUP")).append("','").append(rs5.getString("REGISTER_TIME")).append("','").append(rs5.getString("TYPE")).append("','").append(rs5.getString("BALANCE_TYPE")).append("')").toString();

				stock_db.commit();
				stock_db1.commit();
				stock_db.close();
				stock_db1.close();
				response.sendRedirect((new StringBuilder("stock/analyse/getStaticReport_ok_a.jsp?static_report_ID=")).append(static_report_ID).toString());
			} else
			{
				response.sendRedirect("error_conn.htm");
			}
		}
		catch (Exception ex)
		{
			ex.printStackTrace();
		}
	}
}
